package com.comp7940.groupf.tgbot.builder;

import com.comp7940.groupf.tgbot.entity.common.PageResult;
import com.comp7940.groupf.tgbot.entity.common.Result;

public class ResultBuilder {

    public static final Integer CODE_SUCCESS = 0;

    public static final Integer CODE_FAIL = 1;

    public static final String MES_SUCCESS = "OK";

    public static <T> Result<T> buildSuccess(T data){
        Result<T> result = new Result<T>(CODE_SUCCESS,MES_SUCCESS,data);
        return result;
    }

    public static <T> Result<T> buildSuccess(){
        return new Result<T>(CODE_SUCCESS,MES_SUCCESS,null);
    }


    public static <T> PageResult<T> buildPageSuccess(int totalPage, int pageNo, int pageSize, T data){
        PageResult<T> pageResult = new PageResult<>(CODE_SUCCESS,MES_SUCCESS,data,pageNo,pageSize,totalPage);
        return pageResult;
    }


    public static <T> Result<T> buildFail(Integer code,String msg){
        Result<T> result = new Result<T>(code,msg,null);
        return result;
    }
}
